<template>
	<view>
		<uni-nav-bar title="城市地铁" rightIcon="list" leftIcon="back" @clickRight="torig" @clickLeft="toleft"></uni-nav-bar>
		<view class="u-flex u-demo" >
			<view style="width: 30%;">位置：建国门</view>
			<uni-search-bar placeholder="搜索路线" style="width: 70%;"></uni-search-bar>
		</view>
		<uni-card v-for="(item,index) in luxian" :title="item.lineName" @click="nes(item.lineId)">
			<view style="border-bottom: 1px dashed #000000;">
				<view>下一站：{{item.nextStep.name}}</view>
				<view>到达本站时长：{{item.reachTime}}</view>
			</view>
		</uni-card>
		
	</view>
</template>

<script>
	import api from 'commer/apiURL.js'
	export default {
		data() {
			return {
				base: api.baseurl,
				luxian:[]
			}
		},
		onLoad() {
			this.getlun()
		},
		methods: {
			torig(){
				uni.navigateTo({
					url:'dite'
				})
			},
			toleft(){
				uni.switchTab({
					url: '../allserver'
				})
			},
			nes(id){
				uni.navigateTo({
					url:'xiangqi?id='+id
				})
			},
			getlun() {
				this.$get(this.base + '/prod-api/api/metro/list',{
					currentName:'建国门'
				}).then((res) => {
					this.luxian =this.arr(res.data)
					console.log(res.data)
				})
			},
			arr(arr){
				for(var i=0;i<arr.length-1;i++){
					for(var j=0;j<arr.length-1;j++){
						if(arr[j].reachTime >arr[j+1].reachTime){
							var str = arr[j]
							arr[j] = arr[j+1] 
							arr[j+1] = str
						}
					}
				}
				return arr
			}
		}
	}
</script>

<style>

</style>
